import { Loading, Notification } from 'element-ui'

let loadingInstance

/** 打开全局loading */
export const openLoading = (config) => {
  loadingInstance = Loading.service({ fullscreen: true, text: '加载中...' })
  return config
}

/** 关闭loading */
export const closeLoading = (response) => {
  loadingInstance.close()
  return response
}
/** 异常关闭loading */
export const closeLoadingByException = (error) => {
  loadingInstance.close()
  Notification.error(error.message)
  return Promise.reject(error)
}
